#!/bin/bash
# show git branch discription
# Copy from Internet

show_help () {
	  
	echo ""
	echo "my-git.sh [-h|-lb]"
	echo "---------------------"
	echo "-h: show help information"
	echo "-lb: show branches with descriptions"
	echo ""

}

# Shows branches with descriptions
function gb() {
  current=$(git rev-parse --abbrev-ref HEAD)
  branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
  for branch in $branches; do
    desc=$(git config branch.$branch.description)
    if [ $branch == $current ]; then
      branch="* \033[0;32m$branch\033[0m"
     else
       branch="  $branch"
     fi
     echo -e "$branch \033[0;36m$desc\033[0m"
  done
}

case $1 in
	"-h")
		show_help;;
	"-lb" )
		gb;;
	"-log" )
		git log --graph --oneline;;
	* )
		show_help;;
esac
